package com.xiaoxin.controller;


import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.xiaoxin.common.dto.ResponseBody;
import com.xiaoxin.entity.SysPermission;
import com.xiaoxin.entity.vo.PermissionVo;
import com.xiaoxin.service.ISysPermissionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author TongRui
 * @since 2021-11-28
 */
@Slf4j
@RestController
@RequestMapping("/permission")
public class SysPermissionController {

    @Autowired
    private ISysPermissionService permissionService;

    @PostMapping
    public ResponseBody add(@RequestBody PermissionVo permission){
        SysPermission sysPermission = new SysPermission();
        BeanUtils.copyProperties(permission, sysPermission);
        permissionService.save(sysPermission);
        return ResponseBody.ok(sysPermission.getId());
    }

}

